package cn.com.twoke.application.game.mario.core.ecs.component.render.texture;

import cn.com.twoke.application.game.mario.resource.texture.TextureFactory;
import cn.com.twoke.application.game.mario.core.ecs.component.PositionComponent;
import cn.com.twoke.application.game.mario.core.ecs.component.render.RenderComponentHandler;
import cn.com.twoke.application.game.mario.core.ecs.entity.Entity;

import java.awt.*;
import java.awt.image.BufferedImage;

public class TextureRenderComponentHandler implements RenderComponentHandler<TextureRenderComponent> {


    @Override
    public void handle(Entity entity, BufferedImage container, Graphics2D g, TextureRenderComponent component) {
        if (entity.hasComponent(PositionComponent.class)) {
            TextureFactory.render(entity, entity.getComponent(PositionComponent.class), component.getTextureId(), g);
        }
    }


}
